package com.xw.tools.factory;

import com.xw.tools.view.Base64ToFileWin;
import com.xw.tools.view.Base64Win;
import com.xw.tools.view.CustomizeTextConvertWin;
import com.xw.tools.view.DDLCreateTableWin;
import com.xw.tools.view.DDLAddColumnWin;
import com.xw.tools.view.FileToBase64Win;
import com.xw.tools.view.FileToMd5Win;
import com.xw.tools.view.JsonFormatWin;
import com.xw.tools.view.Md5Win;
import com.xw.tools.view.PasswordNotepadWin;
import com.xw.tools.view.QRCodeWin;
import com.xw.tools.view.SingleLineWin;
import com.xw.tools.view.ZipWin;
import com.xw.tools.view.XmlFormatWin;
import com.xw.tools.view.UnZipWin;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class WinFactory {

    private static Map<String, Map<String, Class>> winMap = new LinkedHashMap<>();

    static {
        Map<String, Class> toolMap = new LinkedHashMap<>();
        toolMap.put("base64", Base64Win.class);
        toolMap.put("fileToBase64", FileToBase64Win.class);
        toolMap.put("base64ToFile", Base64ToFileWin.class);
        toolMap.put("md5", Md5Win.class);
        toolMap.put("文件md5签名", FileToMd5Win.class);
        toolMap.put("单行文本", SingleLineWin.class);
        toolMap.put("自定义文本转换", CustomizeTextConvertWin.class);

        Map<String, Class> toolMap2 = new LinkedHashMap<>();
        toolMap2.put("JSON格式化", JsonFormatWin.class);
        toolMap2.put("XML格式化", XmlFormatWin.class);

        Map<String, Class> toolMap3 = new LinkedHashMap<>();
        toolMap3.put("添加字段",  DDLAddColumnWin.class);
        toolMap3.put("创建表",  DDLCreateTableWin.class);

        Map<String, Class> personalToolMap = new LinkedHashMap<>();
        personalToolMap.put("密码记事本",  PasswordNotepadWin.class);
        personalToolMap.put("二维码",  QRCodeWin.class);

        Map<String, Class> zipMap = new LinkedHashMap<>();
        zipMap.put("zip压缩",  ZipWin.class);
        zipMap.put("zip解压",  UnZipWin.class);

        winMap.put("编码解码", toolMap);
        winMap.put("格式化", toolMap2);
        winMap.put("数据库", toolMap3);
        winMap.put("zip压缩", zipMap);
        winMap.put("个人", personalToolMap);
    }

    public static Class get(String menu, String name) {
        return winMap.get(menu).get(name);
    }

    public static List<String> getNames() {
        return new ArrayList<>(winMap.keySet());
    }

    public static List<String> getItemNames(String menuName) {
        return new ArrayList<>(winMap.get(menuName).keySet());
    }
}
